var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: false,
		title: null,
		settings: {}
	},
	methods: {
		query: function () {
			vm.reload();
		},
		add: function(){
			vm.showList = false;
			vm.title = "新增";
			vm.settings = {};
		},
		update: function (event) {
			var id = getSelectedRow();
			if(id == null){
				return ;
			}
			vm.showList = false;
            vm.title = "修改";
            
            vm.getInfo(id)
		},
		searchMap: function(e){
			local.search(vm.settings.address);
		},
		detail: function () {
	        vm.title = "修改";
	        vm.getInfo(1);
		},
		saveOrUpdate: function (event) {
			var url = vm.settings.id == null ? "settings/save" : "settings/update";
			$.ajax({
				type: "POST",
			    url: baseURL + url,
                contentType: "application/json",
			    data: JSON.stringify(vm.settings),
			    success: function(r){
			    	if(r.code === 0){
						alert('操作成功', function(index){
						});
					}else{
						alert(r.msg);
					}
				}
			});
		},
		del: function (event) {
			var ids = getSelectedRows();
			if(ids == null){
				return ;
			}
			
			confirm('确定要删除选中的记录？', function(){
				$.ajax({
					type: "POST",
				    url: baseURL + "settings/delete",
                    contentType: "application/json",
				    data: JSON.stringify(ids),
				    success: function(r){
						if(r.code == 0){
							alert('操作成功', function(index){
								$("#jqGrid").trigger("reloadGrid");
							});
						}else{
							alert(r.msg);
						}
					}
				});
			});
		},
		getInfo: function(id){
			$.get(baseURL + "settings/info/"+id, function(r){
                vm.settings = r.settings;
            });
		}
	}
});
vm.detail();